__author__ = 'DSperansky'

from php4dvd.pages.internal_page import InternalPage
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as ec


class AddMoviePage(InternalPage):

    @property
    def title_field(self):
        title_field_css_locator = "input[name='name']"
        return self.wait.until(ec.visibility_of_element_located((By.CSS_SELECTOR, title_field_css_locator)))

    @property
    def year_field(self):
        year_field_css_locator = "input[name='year']"
        return self.wait.until(ec.visibility_of_element_located((By.CSS_SELECTOR, year_field_css_locator)))

    @property
    def notes_field(self):
        notes_field_css_locator = "textarea[name='notes']"
        return self.wait.until(ec.visibility_of_element_located((By.CSS_SELECTOR, notes_field_css_locator)))

    @property
    def save_button(self):
        save_button_css_locator = "input#submit"
        return self.wait.until(ec.visibility_of_element_located((By.CSS_SELECTOR, save_button_css_locator)))

    @property
    def is_this_page(self):
        return self.is_element_visible((By.CSS_SELECTOR, "input[name='year']"))
